//
//  MessageViewController.m
//  TT
//
//  Created by lanou3g on 16/3/10.
//  Copyright © 2016年 Super磊. All rights reserved.
//

#import "MessageViewController.h"
#import "mimiViewController.h"
#import "FriendViewController.h"
#import "chatViewController.h"
#import <EaseMob.h>
@interface MessageViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic, strong)UILabel *matchNumber;
@property(nonatomic, strong)NSMutableArray *arrayConversation;

@end

@implementation MessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //   背景图
    UIImageView *imV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"pink.jpg"]];
    imV.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
    [self.view insertSubview:imV atIndex:0];
    //    毛玻璃效果
    UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:(UIBlurEffectStyleLight)];
    UIVisualEffectView *view = [[UIVisualEffectView alloc]initWithEffect:beffect];
    view.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
    view.backgroundColor = [UIColor grayColor];
    view.alpha = 0.6;
    [imV addSubview:view];
    
    //显示配对数
    self.matchNumber = [[UILabel alloc] initWithFrame:CGRectMake(80, 30, 290, 30)];
    self.matchNumber.text = [NSString stringWithFormat:@"%d个配对",2];
    self.matchNumber.backgroundColor = [UIColor clearColor];
    self.matchNumber.textAlignment = NSTextAlignmentCenter;
    self.matchNumber.textColor = [UIColor whiteColor];
    [self.view addSubview:self.matchNumber];
    
    //   朋友圈点击按钮
#warning 重新定义朋友圈
    UIButton *friend = [UIButton buttonWithType:(UIButtonTypeSystem)];
    friend.backgroundColor = [UIColor grayColor];
    friend.frame = CGRectMake(80, CGRectGetMaxY(self.matchNumber.frame) + 20, 290, 50);
    [friend setTitle:@"朋友圈" forState:(UIControlStateNormal)];
    [friend addTarget:self action:@selector(friendAction) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:friend];
    
    //    按钮
    NSArray *arr = @[@"所有配对",@"聊天"];
    UISegmentedControl *segmented = [[UISegmentedControl alloc]initWithItems:arr];
    segmented.frame = CGRectMake(80, CGRectGetMaxY(friend.frame) + 10, 290, 30);
    segmented.tintColor = [UIColor whiteColor];
    //默认选中第一个
    segmented.selectedSegmentIndex = 0;
    [self.view addSubview:segmented];
    
    //    tableview
    UITableView *tableV = [[UITableView alloc]initWithFrame:CGRectMake(80, CGRectGetMaxY(segmented.frame) + 20, 290, kScreenHeight) style:(UITableViewStylePlain)];
    tableV.delegate = self;
    tableV.dataSource = self;
    tableV.backgroundColor = [UIColor clearColor];
    
    [self.view addSubview:tableV];
    
}
-(void)friendAction {
    
    FriendViewController *friend =[FriendViewController new];
    [self presentViewController:friend animated:YES completion:nil];
    
    
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cell_id = @"cell_id";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cell_id];
    if (!cell) {
        cell = [[UITableViewCell alloc]init];
    }
    cell.backgroundColor = [UIColor clearColor];
    cell.imageView.image = [UIImage imageNamed:@"image_default_profile.png"];
    cell.imageView.layer.cornerRadius = 20;
    cell.imageView.layer.masksToBounds = YES;
    cell.textLabel.text = @"Echo";
    cell.detailTextLabel.text = [NSString stringWithFormat:@"配对于%@",@"03/10"];
    return cell;
    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    chatViewController *chat = [chatViewController new];
    /*
     UINavigationController *chat_na =[[UINavigationController alloc]initWithRootViewController:chat];
     AppDelegate *app =[UIApplication sharedApplication].delegate;
     [app.draw setRootViewController:chat_na];
     */
    
    //设置model
//    chat.number = self.arrayConversation[indexPath.row];

    [self presentViewController:chat animated:YES completion:nil];
    
}
#pragma mark
- (NSArray *)arrayConversation {
    if (!_arrayConversation) {
        _arrayConversation = [NSMutableArray new];
    }
    return _arrayConversation;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
